package top.chukongxiang.monitorservice.tools;

import cn.hutool.core.util.StrUtil;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;

/**
 * @author 楚孔响
 * @version 1.0
 * @date 2023/10/27 09:24
 */
public class FxUtil {

    public static Toggle getToggleByUserData(ToggleGroup toggleGroup, String userData) {
        if (userData == null) {
            return null;
        }
        if (toggleGroup == null) {
            return null;
        }
        for (Toggle toggle : toggleGroup.getToggles()) {
            if (StrUtil.equals(StrUtil.toStringOrNull(toggle.getUserData()), userData)) {
                return toggle;
            }
        }
        return null;
    }

}
